package utils

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	Success = 0
	ServerError = 50001
	LogicError = 50002
)

func ResponseError(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": ServerError,
	})
}

func ResponseErrorWithMsg(msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": ServerError,
		"msg": msg,
	})
}


func ResponseFail(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": LogicError,
		"msg": "操作失败",
	})
}

func ResponseFailWithMsg(msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": LogicError,
		"msg": msg,
	})
}

func ResponseSuccess(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": Success,
		"msg": "操作成功",
	})
}

func ResponseSuccessWithData(data map[string]interface{}, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": Success,
		"msg": "操作成功",
		"data": data,
	})
}

func ResponseSuccessWithDataMsg(data map[string]interface{}, msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": Success,
		"msg": msg,
		"data": data,
	})
}
